/**
 * @Name:  Article
 * @Author:
 * @Desc:  文章显示
 * @Date: 2020-12-07 10:29:09
 */

import React, { Component } from "react";
import { getSearchObject } from "@/utils";
import styles from "./styles.module.less";

class Article extends Component {
  state = {
    title: "",
    content: ""
  };
  componentDidMount() {
    const { title, content } = getSearchObject();
    this.setState({ title, content });
  }
  /**
   * @name goBack
   * @description 返回上一页，如果跳转到此页面的方法是打开新页面，或是replace方法，则不起作用
   */
  goBack = () => {
    window.history.go(-1);
  };
  render() {
    const { title, content } = this.state;
    return (
      <div className={styles.container}>
        <h2 className={styles.title}>{title}</h2>
        <div className={styles.back_body}>
          <p className={styles.back} onClick={this.goBack}>
            返回
          </p>
        </div>
        <div dangerouslySetInnerHTML={{ __html: content }}></div>
      </div>
    );
  }
}
export default Article;
